package ex;

public class Ex4 {
    //字符倒序
    public static void main(String[] args) {
        System.out.println("==== SrringBuilder反转内容 ====");
        String s1 = "wzby0420";
        System.out.println(s1);
        StringBuilder s2 = new StringBuilder(s1);
        System.out.println(s2);
        System.out.println(s2.reverse());
        //.reverse()反转内容

        System.out.println("==== .charAt()方法 ====");
        String a = "hello wzby ok";
        System.out.println(a.charAt(0));
        //.charAt(0)检索内容里第一个字符
        System.out.println(a.charAt(a.length() - 1));
        //a.charAt(a.length()-1)检索内容里最后一个字符


        System.out.println("==== 字母倒序 ====");
        String s3 = "wzby1013";
        String s4 = "";
        for (int i = 0; i < s3.length(); i++) {
            s4 = s3.charAt(i) + s4;
        }
        System.out.println(s3);
        System.out.println(s4);
    }
}

